//
//  QDCopygraphViewController-Swift.swift
//  QDMetroClient
//
//  Created by YueWen on 2019/3/10.
//  Copyright © 2019 YueWen. All rights reserved.
//

import Foundation

/// 自助补站选站
extension QDCopygraphViewController {
    
    /// 填出地铁站点
    @objc func pushSelectedStationViewController(){
        router(platform: .stations(type: .select, delegate: self))
    }
    
    /// 请求自助补站
    @objc func requestSupplement(type: String,stationId: String, explain: String? = ""){
        
        /// 延迟1s返回
        func popAfterOneSecond(){
            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
                self.navigationController?.popViewController(animated: true)
            }
        }
        
        view.showTextHUD(text: "正在进行补站")
        
        QDNetworkingManager.request(url: QDTicketHostUrl + "/self/request_supplement", paramteres: ["cardType":type,"stationId":stationId,"explain":explain ?? ""], success: { (msg, data) in
            
            self.view.showTextHUD(text: "自助补站成功")
            popAfterOneSecond()
            
        }) { (msg, errorType) in
            
            self.view.showTextHUD(text: msg)

        }
    }
}



extension QDCopygraphViewController: QDStationsViewSelectAction {
    
    func stationsViewController(didSelect stationName: String, stationId: String, line: [String]) {
        
        //设置属性
        self.outStationId = stationId
        self.second = true
        self.stationName?.setTitle(stationName, for: .normal)
        self.stationName?.setTitleColor(QDColors.theme, for: .normal)
    }
    
}
